package com.vogue.supplymall.account.domain.service.impl;

import java.util.List;
import java.util.Map;

import com.vogue.supplymall.account.domain.mapper.CodeMapper;
import com.vogue.supplymall.common.domain.dto.admin.OrganSearchInfo;
import org.springframework.stereotype.Service;
import com.vogue.ssm.database.dao.BaseDao;
import com.vogue.supplymall.account.domain.dao.CodeDao;
import com.vogue.supplymall.account.domain.model.BaseCode;
import com.vogue.supplymall.account.domain.service.BaseCodeService;

@Service("baseCodeService")
public class BaseCodeServiceImpl extends BaseServiceImpl<BaseCode, Long> implements BaseCodeService{
	
	private CodeDao codeDao;
	
	public BaseCodeServiceImpl(BaseDao<BaseCode, Long> baseDao) {
        super(baseDao);
        codeDao=(CodeDao)baseDao;
	}

	@Override
	public List<Map<Long, Long>> syscodeExisted() {
		return codeDao.syscodeExisted();
	}
	
	@Override
	public Long checkSysCodeValidity(Long sysCode) {
		Long id=(long) 0;
		List<Long> idList=codeDao.checkSysCodeValidity(sysCode);
		if(idList.size()>0&&idList.size()!=0) {
			id=idList.get(0);
		}
		
		return id;
	}

	@Override
	public List<Long> checkSysCodeExist(String sysCodes) {
		List<Long> codeList=codeDao.checkSysCodeExist(sysCodes);
		return codeList;
	}

	@Override
	public List<Map<String, Object>> findValidOrgan(OrganSearchInfo organSearchInfo) {
		return codeDao.findValidOrgan(organSearchInfo);
	}

	@Override
	public Long findValidOrganCount(OrganSearchInfo organSearchInfo) {
		return codeDao.findValidOrganCount(organSearchInfo);
	}

	@Override
	public int updateTpsystemBySyscodeId(Long syscodeId, int tpsystem) {
		String sql="update base_code set tpsystem="+tpsystem
					+" where id="+syscodeId;
		return codeDao.update(sql);
		
	}
	
}
